package design.mode.model.factory.factorymethod.store;

import design.mode.model.factory.coffee.Coffee;
import design.mode.model.factory.factorymethod.factory.comon.CoffeeFactory;

/**
 * @author ldanniel
 * @description 点咖啡（依赖于Coffee），只依赖了抽象，而没有依赖于具体，这符合依赖倒转原则
 * @since jdk11
 */
public class CoffeeStore {
   public CoffeeFactory factory;

    public CoffeeStore(CoffeeFactory factory) {
        this.factory = factory;
    }
    public Coffee orderCoffee(Class cls){
        Coffee coffee = (Coffee)factory.createProduct(cls);
        coffee.addMilk();
        coffee.addSugar();
        return coffee;
    }
}
